import { styled } from 'styled-components';

export const UploaderRender = styled.div`
  display: flex;
  flex-direction: column;
  width: 100%;

  .custom-uploader {
    &.is-horizontal {
      display: flex;
      flex-direction: row;
    }

    .ant-upload {
      &.ant-upload-select {
        margin-bottom: 5px;
        margin-right: 15px;
      }
    }
    .ant-upload-list {
      &.ant-upload-list-picture-card {
        .ant-upload.ant-upload-select {
          .uploader-btn {
            height: auto;
            padding: 4px 10px;
            border-color: transparent;
            background-color: transparent;
            box-shadow: none;
          }
        }

        .uploader-list-item {
          .uploader-list-info {
            flex-direction: column;
            .uploader-list-icon {
              align-items: center;
              justify-content: center;
              padding: 4px;
              max-width: 100px;
              max-height: 100px;

              img {
                width: 100%;
                height: auto;
                max-width: 100%;
                max-height: 100%;
                border-radius: 4px;
                color: #415fff;
              }

              svg {
                width: 48px;
                height: 48px;
                color: #a1a1a1;
              }
            }
            .uploader-list-name {
              display: none;
              position: absolute;
              right: 4px;
              bottom: 4px;
              left: 4px;
              text-align: center;
              justify-content: center;
            }
          }
          .uploader-list-action {
            display: none;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
          }

          &:hover {
            &:after {
              content: '';
              position: absolute;
              top: 4px;
              right: 4px;
              bottom: 4px;
              left: 4px;
              z-index: 0;
              background-color: rgba(0, 0, 0, 0.45);
              border-radius: 4px;
              transition: all 0.3s;
            }

            .uploader-list-name,
            .uploader-list-action {
              z-index: 1;
              display: flex;
              color: rgba(255, 255, 255, 0.8);
            }

            .uploader-list-view,
            .uploader-list-remove {
              &:hover {
                color: #fff;
              }
            }
          }
        }
      }
    }
  }
  /** 特殊定制上传按钮和图片预览：16：9 */
  .custom-uploader-special {
    .ant-upload {
      &.ant-upload-select-picture-card {
        /** 默认:104*104, 修改成16:9*/
        width: 240px;
        height: 135px;
      }
    }

    .ant-upload-list {
      &.ant-upload-list-picture-card {
        .ant-upload-list-picture-card-container {
          /** 默认:104*104, 修改成16:9*/
          width: 240px;
          height: 135px;
          .uploader-list-item {
            .uploader-list-info {
              .uploader-list-icon {
                max-width: 100%;
                max-height: 100%;
              }
            }
          }
        }
      }
    }
  }
`;

// 自定义渲染上传文件列表
export const UploaderListItemRender = styled.div`
  &.uploader-list-item {
    position: relative;
    list-style: none;
    clear: none;
    width: 100%;
    height: 100%;
    line-height: 22px;
    margin: 0 auto 5px auto;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #eee;
    border-radius: 4px;

    .uploader-list-info {
      display: flex;
      flex-direction: row;
      flex: 1;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      .uploader-list-icon {
        display: inline-flex;
        flex: 0 0 auto;
        padding: 4px 8px;

        img,
        svg {
          width: 22px;
          height: 22px;
          border-radius: 4px;
          color: #415fff;
        }
        svg {
          width: 18px;
        }
      }
      .uploader-list-name {
        display: flex;
      }
    }
    .uploader-list-action {
      display: flex;
      flex-direction: row;
      flex: 0 0 auto;

      .uploader-list-view,
      .uploader-list-remove {
        padding: 0 5px;
        cursor: pointer;
      }
      .uploader-list-view {
        &:hover {
          color: #415fff;
        }
      }
      .uploader-list-remove {
        &:hover {
          color: #ff6941;
        }
      }
    }
  }
`;

// 历史文件
export const UploaderHistoryRender = styled.div`
  &.uploader-history {
    margin-top: 16px;
    display: flex;
    flex-direction: column;

    .uploader-history-title {
      margin-bottom: 5px;
      font-size: 14px;
      font-weight: bold;
      color: #353535;
    }
    .uploader-history-content {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
    }
  }
`;
